//
//  ViewController.m
//  30504
//
//  Created by student on 16/4/5.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
{
    SystemSoundID soundID;
}
@property (weak, nonatomic) IBOutlet UIImageView *imageview;




@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.imageview.image=[UIImage imageNamed:@"home"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if(soundID==0)
    {
        NSURL *fileurl=[[NSBundle mainBundle]URLForResource:@"glass" withExtension:@"wav"];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(fileurl), &soundID);
    }
    AudioServicesPlaySystemSound(soundID);
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    self.imageview.image=[UIImage imageNamed:@"homebroken"];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    self.imageview.image=[UIImage imageNamed:@"home"];
}
@end
